home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KDFrame.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  39.0 KB  |  1,168 lines

  1. /* -*- Mode: C++ -*-
  2.    KDChart - a multi-platform charting engine
  3.    */
  4.  
  5. /****************************************************************************
  6.  ** Copyright (C) 2001-2003 Klar├ñlvdalens Datakonsult AB.  All rights reserved.
  7.  **
  8.  ** This file is part of the KDChart library.
  9.  **
  10.  ** This file may be distributed and/or modified under the terms of the
  11.  ** GNU General Public License version 2 as published by the Free Software
  12.  ** Foundation and appearing in the file LICENSE.GPL included in the
  13.  ** packaging of this file.
  14.  **
  15.  ** Licensees holding valid commercial KDChart licenses may use this file in
  16.  ** accordance with the KDChart Commercial License Agreement provided with
  17.  ** the Software.
  18.  **
  19.  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20.  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21.  **
  22.  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
  23.  **   information about KDChart Commercial License Agreements.
  24.  **
  25.  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  26.  ** licensing are not clear to you.
  27.  **
  28.  **********************************************************************/
  29. #ifndef __KDFRAME_H__
  30. #define __KDFRAME_H__
  31.  
  32. #include <qapplication.h>
  33. #include <qfont.h>
  34. #include <qcolor.h>
  35. #include <qpixmap.h>
  36. #include <qpen.h>
  37. #include <qmap.h>
  38. #include <qobject.h>
  39. #include <qtextstream.h>
  40. #include <qdom.h>
  41.  
  42. #include <KDFrameProfileSection.h>
  43.  
  44.  
  45. /** \file KDFrame.h
  46.   \brief Header of the KDFrame class providing highly configurable rectangular frame drawing.
  47.  
  48.   \ifnot v200
  49.   This class is work in progress, at present only single line frame borders
  50.   and (scaled/streched) background pictures are available.
  51.   See KDChartParams::setSimpleFrame() to learn how to use them.
  52.   \else
  53.   A frame may consist of an (optional) border and/or an (optional) background.
  54.   The border may consist of up to four edges and/or up to four border corners.
  55.  
  56.   \note Each of the edges and each of the corners may use their own user-definable profile.
  57.  
  58.   The frame corners ( see types defined in \c CornerStyle ) are set up via setCorner()
  59.  
  60.   Some commonly used frame profiles (e.g. raised box, sunken panel) are predefined in \c SimpleFrame, see setSimpleFrame().
  61.   To learn how to specify your frame profiles have a look at example code given with setProfile()
  62.   \endif
  63.   */
  64.  
  65.  
  66. /**
  67.   \brief The main class of KDFrame.
  68.  
  69.   KDFrame is made for highly configurable rectangular frame drawing.
  70.  
  71.   A frame may consist of an (optional) border and/or an (optional) background.
  72.   \ifndef v200
  73.   This class is work in progress, at present only single line frame borders
  74.   and (scaled/streched) background pictures are available.
  75.   See KDChartParams::setSimpleFrame() to learn how to use them.
  76.   \else
  77.   The border may consist of up to four edges and/or up to four border corners.
  78.  
  79.   \note Each of the edges and each of the corners may use their own user-definable profile.
  80.  
  81.   The frame corners ( see types defined in CornerStyle ) are set up via setCorner()
  82.  
  83.   Some commonly used frame profiles (e.g. raised box, sunken panel) are predefined in SimpleFrame, see setSimpleFrame().
  84.   To learn how to specify your frame profiles have a look at example code given with setProfile()
  85.   \endif
  86.   */
  87. class KDCHART_EXPORT KDFrame : public QObject
  88. {
  89.     Q_OBJECT
  90.     Q_ENUMS( BackPixmapMode )
  91.     Q_ENUMS( SimpleFrame )
  92.     Q_ENUMS( ProfileName )
  93.     Q_ENUMS( CornerName )
  94.     Q_ENUMS( CornerStyle )
  95.     Q_ENUMS( KDFramePaintSteps )
  96.  
  97. public:
  98.     //// GENERAL
  99.  
  100.  
  101.     /**
  102.     These are ways how to display a pixmap that might
  103.     be painted into the inner area.
  104.  
  105.     \Note To have a 'tiled' background image do not use a background
  106.     pixmap but use a background <b>brush</b> holding this pixmap.
  107.     */
  108.     enum BackPixmapMode { PixCentered, PixScaled, PixStretched };
  109.  
  110. public slots:
  111.  
  112.     /**
  113.     Converts the specified background pixmap mode enum to a string
  114.     representation.
  115.  
  116.     \param type the background pixmap mode to convert
  117.     \return the string representation of the background pixmap mode enum
  118.     */
  119.     static QString backPixmapModeToString( BackPixmapMode type ) {
  120.         switch( type ) {
  121.             case PixCentered:
  122.                 return "Centered";
  123.             case PixScaled:
  124.                 return "Scaled";
  125.             case PixStretched:
  126.                 return "Stretched";
  127.         }
  128.  
  129.         return "Stretched";
  130.     }
  131.  
  132.  
  133.     /**
  134.     Converts the specified string to a background pixmap mode enum value.
  135.  
  136.     \param string the string to convert
  137.     \return the background pixmap mode enum value
  138.     */
  139.     static BackPixmapMode stringToBackPixmapMode( const QString& string ) {
  140.         if( string == "Centered" )
  141.             return PixCentered;
  142.         else if( string == "Scaled" )
  143.             return PixScaled;
  144.         else if( string == "Stretched" )
  145.             return PixStretched;
  146.  
  147.         return PixStretched;
  148.     }
  149.  
  150.  
  151. public:
  152.  
  153.  
  154.     /**
  155.     These simple frames are pre-defined for your convenience
  156.  
  157.     \li \c FrameFlat a flat rectangular frame
  158.     \li \c FrameElegance a flat frame consisting of three lines
  159.     \li \c FrameBoxRaized a raised box
  160.     \li \c FrameBoxSunken a sunken box
  161.     \li \c FramePanelRaized a raised panel
  162.     \li \c FramePanelSunken a sunken panel
  163.     \li \c FrameSemicircular a raised box with round edges
  164.  
  165.     \ifnot v200
  166.     All pre-defined frames have normal corners.
  167.     \else
  168.     All pre-defined frames have normal corners but
  169.     of course you may specify differently looking corners by
  170.     calling setCorners() (or setCorner(), resp.) after having
  171.     called setSimpleFrame()
  172.  
  173.     \sa setSimpleFrame
  174.     \endif
  175.     */
  176.     enum SimpleFrame { FrameFlat,        FrameElegance,
  177.         FrameBoxRaized,   FrameBoxSunken,
  178.         FramePanelRaized, FramePanelSunken,
  179.         FrameSemicircular };
  180.  
  181. public slots:
  182.  
  183.     /**
  184.     \ifnot v200
  185.     \deprecated Feature scheduled for future release, at present not implemented.
  186.     \else
  187.     Select a pre-defined frame.
  188.     This methode is provided for convenience, the same results can be obtained by calling
  189.     addProfileSection multiple times specifying the appropriate parameters and finally
  190.     setting the corners to \c CornerNormal
  191.  
  192.     \note When using FrameElegance the midLineWidth value will be ignored since
  193.     in this special case the lineValue will indicate the <b>total width</b> of the frame.
  194.     FrameElegance frames look best when lineWidth is 16 or the multiple of 16.
  195.  
  196.     \Note To have a 'tiled' background image do not use a background
  197.     pixmap but use a background <b>brush</b> holding this pixmap.
  198.  
  199.     See setProfile for a short example using this method.
  200.  
  201.     \param frame one of the values defined for enum \c SimpleFrame
  202.     \param lineWidth for FrameFlat and FrameElegance: the complete frame width;
  203.         for frames with 2-line edges (FramePanelRaized, FramePanelSunken): the width of each of the lines;
  204.         for frames with 3-line edges (FrameBoxRaized, FrameBoxSunken, FrameSemicircular): the width of the outer and the
  205.         width of the inner line.
  206.     \param midLineWidth only used for frames with 3-line edges: the width
  207.         of the middle line.
  208.     \param pen the basic pen to be used for this frame's lines
  209.     \param background the brush to be used for the frame's background or QBrush() if the background is not to be filled by a brush
  210.     \param backPixmap if not zero points to a pixmap to be used for the background
  211.     \param backPixmapMode determines how the size pixmap is adjusted to the frame size,
  212.         see \c BackPixmapMode for the possible values.
  213.  
  214.     \sa SimpleFrame, BackPixmapMode, addProfileSection, setProfile, profile, setCorners, setCorner, cornerStyle, cornerWidth
  215.     \endif
  216.     */
  217.     void setSimpleFrame( SimpleFrame    frame,
  218.             int            lineWidth,
  219.             int            midLineWidth,
  220.             QPen           pen,
  221.             QBrush         background     = QBrush(),
  222.             const QPixmap* backPixmap     = 0,
  223.             BackPixmapMode backPixmapMode = PixStretched );
  224.  
  225. public:
  226.     /**
  227.     \ifnot v200
  228.     \deprecated Feature scheduled for future release, at present not implemented.
  229.     \else
  230.     Names of the four frame edges
  231.  
  232.     \li \c ProfileTop
  233.     \li \c ProfileRight
  234.     \li \c ProfileBottom
  235.     \li \c ProfileLeft
  236.  
  237.     \sa setSimpleFrame, clearProfile, addProfileSection, setProfile, profile
  238.     \endif
  239.     */
  240.     enum ProfileName { ProfileTop,    ProfileRight,
  241.         ProfileBottom, ProfileLeft };
  242.  
  243. public slots:
  244.     /**
  245.     \ifnot v200
  246.     \deprecated Feature scheduled for future release, at present not implemented.
  247.     \else
  248.     Add another section to one of the frames profiles.
  249.  
  250.     \note The sections will be drawn in the order in which they were added to the profile
  251.     beginning at the outside and ending with the inner section of the frame
  252.  
  253.     See setProfile for a short example using this method.
  254.  
  255.     \sa ProfileName, setSimpleFrame, addProfileSection, setProfile, profile
  256.     \endif
  257.     */
  258.     void clearProfile( ProfileName name );
  259.  
  260.     /**
  261.     \ifnot v200
  262.     \deprecated Feature scheduled for future release, at present not implemented.
  263.     \else
  264.     Add another section to one of the frames profiles.
  265.  
  266.     \note The sections will be drawn in the order in which they were added to the profile
  267.     beginning at the outside and ending with the inner section of the frame.
  268.  
  269.     Adding a gap between two sections can be done by specifying a <b>QPen( Qt::NoPen )</b>.
  270.  
  271.     See setProfile for a short example using this method.
  272.  
  273.     \sa ProfileName, setSimpleFrame, clearProfile, setProfile, profile
  274.     \endif
  275.     */
  276.     void addProfileSection( ProfileName      name,
  277.             int              wid,
  278.             QPen             pen,
  279.             KDFrameProfileSection::Direction dir  = KDFrameProfileSection::DirPlain, // PENDING(blackie) possible enum problem
  280.             KDFrameProfileSection::Curvature curv = KDFrameProfileSection::CvtPlain );
  281.  
  282.     /**
  283.     \ifnot v200
  284.     \deprecated Feature scheduled for future release, at present not implemented.
  285.     \else
  286.     Specify one of the frames profiles by copying another KDFrameProfile.
  287.     Use this function if a profile shall look the same as another one.
  288.  
  289.     <b>Example:</b>
  290.  
  291.     \verbatim
  292.     // instantiate a frame around an inner rectangle 50/20, 250/20
  293.     KDFrame myFrame( 50,20, 250,120 );
  294.  
  295.     // select a very simple rectangular frame with normal corners, black border, white background
  296.     myFrame.setSimpleFrame( KDFrame::FrameFlat, 1, 0, QPen( Qt::Black ), QBrush( Qt::White ) );
  297.  
  298.     // make the top profile look more nice
  299.     myFrame.clearProfile(      KDFrame::ProfileTop );
  300.     myFrame.addProfileSection( KDFrame::ProfileTop, 2, QPen( Qt::Black ),
  301.     KDFrameProfileSection::DirPlain,
  302.     KDFrameProfileSection::CvtPlain );
  303.     myFrame.addProfileSection( KDFrame::ProfileTop, 5, QPen( Qt::NoPen ),
  304.     KDFrameProfileSection::DirPlain,
  305.     KDFrameProfileSection::CvtPlain );
  306.     myFrame.addProfileSection( KDFrame::ProfileTop, 1, QPen( Qt::Black ),
  307.     KDFrameProfileSection::DirPlain,
  308.     KDFrameProfileSection::CvtPlain );
  309.  
  310.     // copy the top profile settings into the bottom profile
  311.     myFrame.setProfile( KDFrame::ProfileBottom,
  312.     myFrame.profile( KDFrame::ProfileTop ) );
  313.     \endverbatim
  314.  
  315.  
  316.     \sa ProfileName, setSimpleFrame, clearProfile, addProfileSection, profile
  317.     \endif
  318.     */
  319.     void setProfile( ProfileName name, const KDFrameProfile& profile );
  320.  
  321.     /**
  322.     \ifnot v200
  323.     \deprecated Feature scheduled for future release, at present not implemented.
  324.     \else
  325.     Return one of the frames profiles.
  326.  
  327.     \sa ProfileName, setSimpleFrame, clearProfile, addProfileSection, setProfile
  328.     \endif
  329.     */
  330.     const KDFrameProfile& profile( ProfileName name ) const;
  331.  
  332. public:
  333.  
  334.     /**
  335.     \ifnot v200
  336.     \deprecated Feature scheduled for future release, at present not implemented.
  337.     \else
  338.     Names of the frame corners:
  339.  
  340.     \li \c CornerTopLeft
  341.     \li \c CornerTopRight
  342.     \li \c CornerBottomLeft
  343.     \li \c CornerBottomRight
  344.  
  345.     \sa setCorners, setCorner, setSunPos, cornerStyle, cornerWidth, sunPos
  346.     \endif
  347.     */
  348.     enum CornerName { CornerTopLeft,
  349.         CornerTopRight,
  350.         CornerBottomLeft,
  351.         CornerBottomRight,
  352.         CornerUNKNOWN };
  353.  
  354. public slots:
  355.     /**
  356.     \ifnot v200
  357.     \deprecated Feature scheduled for future release, at present not implemented.
  358.     \else
  359.     Converts the specified corner name enum to a string representation.
  360.  
  361.     \param type the corner name to convert
  362.     \return the string representation of the corner name enum
  363.     \endif
  364.     */
  365.     static QString cornerNameToString( CornerName type ) {
  366.         switch( type ) {
  367.             case CornerTopLeft:
  368.                 return "TopLeft";
  369.             case CornerTopRight:
  370.                 return "TopRight";
  371.             case CornerBottomLeft:
  372.                 return "BottomLeft";
  373.             case CornerBottomRight:
  374.                 return "BottomRight";
  375.             case CornerUNKNOWN:
  376.                 return "UNKNOWN";
  377.         }
  378.  
  379.         return "UNKNOWN";
  380.     }
  381.  
  382.  
  383.     /**
  384.     \ifnot v200
  385.     \deprecated Feature scheduled for future release, at present not implemented.
  386.     \else
  387.     Converts the specified string to a corner name enum value.
  388.  
  389.     \param string the string to convert
  390.     \return the corner name enum value
  391.     \endif
  392.     */
  393.     static CornerName stringToCornerName( const QString& string ) {
  394.         if( string == "TopLeft" )
  395.             return CornerTopLeft;
  396.         else if( string == "TopRight" )
  397.             return CornerTopRight;
  398.         else if( string == "BottomLeft" )
  399.             return CornerBottomLeft;
  400.         else if( string == "BottomRight" )
  401.             return CornerBottomRight;
  402.         else if( string == "UNKNOWN" )
  403.             return CornerUNKNOWN;
  404.  
  405.         return CornerUNKNOWN;
  406.     }
  407.  
  408. public:
  409.  
  410.  
  411.     /**
  412.     \ifnot v200
  413.     \deprecated Feature scheduled for future release, at present not implemented.
  414.     \else
  415.     Look of the frame corners:
  416.  
  417.     \li \c CornerNormal  a square angle corner.
  418.     \li \c CornerRound   a quarter of a circle.
  419.     \li \c CornerOblique corner cut-off by 45 degrees.
  420.  
  421.     \sa setCorners, setCorner, cornerStyle, cornerWidth
  422.     \endif
  423.     */
  424.     enum CornerStyle { CornerNormal,
  425.         CornerRound,
  426.         CornerOblique };
  427.  
  428. public slots:
  429.         /**
  430.         \ifnot v200
  431.         \deprecated Feature scheduled for future release, at present not implemented.
  432.         \else
  433.         Converts the specified corner style enum to a string representation.
  434.  
  435.         \param type the corner style enum to convert
  436.         \return the string representation of the corner style enum
  437.         \endif
  438.         */
  439.         static QString cornerStyleToString( CornerStyle type ) {
  440.             switch( type ) {
  441.                 case CornerNormal:
  442.                     return "Normal";
  443.                 case CornerRound:
  444.                     return "Round";
  445.                 case CornerOblique:
  446.                     return "Oblique";
  447.             }
  448.  
  449.             return "Normal";
  450.         }
  451.  
  452.  
  453.         /**
  454.         \ifnot v200
  455.         \deprecated Feature scheduled for future release, at present not implemented.
  456.         \else
  457.         Converts the specified string to a corner stylye enum value.
  458.  
  459.         \param string the string to convert
  460.         \return the corner style enum value
  461.         \endif
  462.         */
  463.         static CornerStyle stringToCornerStyle( const QString& string ) {
  464.             if( string == "Normal" )
  465.                 return CornerNormal;
  466.             else if( string == "Round" )
  467.                 return CornerRound;
  468.             else if( string == "Oblique" )
  469.                 return CornerOblique;
  470.  
  471.             return CornerNormal;
  472.         }
  473.  
  474.  
  475. public:
  476.  
  477. // MOC_SKIP_BEGIN
  478.         /**
  479.         \ifnot v200
  480.         \deprecated Feature scheduled for future release, at present not implemented.
  481.         \else
  482.         Helper class storing settings for one corner of the frame.
  483.  
  484.         To set/retrieve information stored in this class please use
  485.         the appropriate methods of the KDFrame class.
  486.  
  487.         \sa setCorners, setCorner, cornerStyle, cornerWidth, cornerProfile, CornerName, CornerStyle
  488.         \endif
  489.         */
  490.     class KDCHART_EXPORT KDFrameCorner
  491.         {
  492.             friend class KDFrame;
  493.             public:
  494.             KDFrameCorner( CornerStyle           style   = CornerNormal,
  495.                     int                   width   = 0,
  496.                     KDFrameProfile* const profile = 0 )
  497.                 : _style( style ),
  498.             _width( width )
  499.             {
  500.                 if( profile )
  501.                     _profile = *profile;
  502.                 else
  503.                     _profile.clear();
  504.             }
  505.             /**
  506.             Destructor. Only defined to have it virtual.
  507.             */
  508.             virtual ~KDFrameCorner();
  509.  
  510.             /**
  511.             \ifnot v200
  512.             \deprecated Feature scheduled for future release, at present not implemented.
  513.             \else
  514.             Creates a DOM element node that represents a frame corner for use
  515.             in a DOM document.
  516.  
  517.             \param document the DOM document to which the node will belong
  518.             \param parent the parent node to which the new node will be appended
  519.             \param elementName the name of the new node
  520.             \param corner the corner to be represented
  521.             \endif
  522.             */
  523.             static void createFrameCornerNode( QDomDocument& document,
  524.                     QDomNode& parent,
  525.                     const QString& elementName,
  526.                     const KDFrameCorner& corner );
  527.  
  528.             /**
  529.             \ifnot v200
  530.             \deprecated Feature scheduled for future release, at present not implemented.
  531.             \else
  532.             Reads data from a DOM element node that represents a frame
  533.             corner and fills a KDFrameCorner object with the data.
  534.  
  535.             \param element the DOM element to read from
  536.             \param corner the frame corner object to read the data into
  537.             \endif
  538.             */
  539.             static bool readFrameCornerNode( const QDomElement& element,
  540.                     KDFrameCorner& corner );
  541.  
  542.             protected:
  543.             void setAll( CornerStyle           style,
  544.                     int                   width,
  545.                     KDFrameProfile* const profile = 0 )
  546.             {
  547.                 _style = style;
  548.                 _width = width;
  549.                 if( profile )
  550.                     _profile = *profile;
  551.                 else
  552.                     _profile.clear();
  553.             }
  554.             CornerStyle style() const
  555.             {
  556.                 return _style;
  557.             }
  558.             int width() const
  559.             {
  560.                 return _width;
  561.             }
  562.             const KDFrameProfile& profile() const
  563.             {
  564.                 return _profile;
  565.             }
  566.             private:
  567.             CornerStyle  _style;
  568.             int          _width;
  569.             KDFrameProfile _profile;
  570.         };
  571.  
  572. // MOC_SKIP_END
  573.  
  574. public slots:
  575.         /**
  576.         \ifnot v200
  577.         \deprecated Feature scheduled for future release, at present not implemented.
  578.         \else
  579.         Specify the look and the width and (optionally) the profile
  580.         of one of the frame corners.
  581.  
  582.         \sa setCorners, cornerStyle, cornerWidth, cornerWidth, CornerName, CornerStyle
  583.         \endif
  584.         */
  585.         void setCorner( CornerName name,
  586.                 CornerStyle style,
  587.                 int width,
  588.                 KDFrameProfile* const profile = 0 )
  589.         {
  590.             switch( name ) {
  591.                 case CornerTopLeft:     _cornerTL.setAll( style, width, profile );
  592.                                         break;
  593.                 case CornerTopRight:    _cornerTR.setAll( style, width, profile );
  594.                                         break;
  595.                 case CornerBottomLeft:  _cornerBL.setAll( style, width, profile );
  596.                                         break;
  597.                 case CornerBottomRight: _cornerBR.setAll( style, width, profile );
  598.                                         break;
  599.                 case CornerUNKNOWN:
  600.                                         break;
  601.             }
  602.         }
  603.  
  604.         /**
  605.         \ifnot v200
  606.         \deprecated Feature scheduled for future release, at present not implemented.
  607.         \else
  608.         Specify the look and the width and (optionally) the profile
  609.         of all of the frame corners.
  610.  
  611.         \sa setCorner, cornerStyle, cornerWidth, CornerName, CornerStyle
  612.         \endif
  613.         */
  614.         void setCorners( CornerStyle style,
  615.                 int width,
  616.                 KDFrameProfile* const profile = 0 )
  617.         {
  618.             _cornerTL.setAll( style, width, profile );
  619.             _cornerTR.setAll( style, width, profile );
  620.             _cornerBL.setAll( style, width, profile );
  621.             _cornerBR.setAll( style, width, profile );
  622.         }
  623.  
  624.  
  625.         /**
  626.         \ifnot v200
  627.         \deprecated Feature scheduled for future release, at present not implemented.
  628.         \else
  629.         Returns the look of one of the frame corners.
  630.  
  631.         \sa setCorners, cornerWidth, CornerName, CornerStyle
  632.         \endif
  633.         */
  634.         CornerStyle cornerStyle( CornerName name ) const
  635.         {
  636.             switch( name ) {
  637.                 case CornerTopLeft:     return _cornerTL.style();
  638.                 case CornerTopRight:    return _cornerTR.style();
  639.                 case CornerBottomLeft:  return _cornerBL.style();
  640.                 case CornerBottomRight: return _cornerBR.style();
  641.                 case CornerUNKNOWN:
  642.                 default:                return CornerNormal;
  643.             }
  644.         }
  645.  
  646.         /**
  647.         \ifnot v200
  648.         \deprecated Feature scheduled for future release, at present not implemented.
  649.         \else
  650.         Returns the width of one of the frame corners.
  651.  
  652.         \sa setCorners, cornerStyle, CornerName, CornerStyle
  653.         \endif
  654.         */
  655.         int cornerWidth( CornerName name ) const
  656.         {
  657.             switch( name ) {
  658.                 case CornerTopLeft:     return _cornerTL.width();
  659.                 case CornerTopRight:    return _cornerTR.width();
  660.                 case CornerBottomLeft:  return _cornerBL.width();
  661.                 case CornerBottomRight: return _cornerBR.width();
  662.                 case CornerUNKNOWN:
  663.                 default:                return 0;
  664.             }
  665.         }
  666.  
  667.         /**
  668.         \ifnot v200
  669.         \deprecated Feature scheduled for future release, at present not implemented.
  670.         \else
  671.         Returns the profile of one of the frame corners.
  672.  
  673.         \sa setCorners, cornerStyle, CornerName, CornerStyle
  674.         \endif
  675.         */
  676.         const KDFrameProfile& cornerProfile( CornerName name ) const
  677.         {
  678.             switch( name ) {
  679.                 case CornerUNKNOWN:
  680.                 case CornerTopLeft:     return _cornerTL.profile();
  681.                 case CornerTopRight:    return _cornerTR.profile();
  682.                 case CornerBottomLeft:  return _cornerBL.profile();
  683.                 case CornerBottomRight: return _cornerBR.profile();
  684.                 default: return _cornerTL.profile();
  685.             }
  686.         }
  687.  
  688.  
  689.         /**
  690.         \ifnot v200
  691.         \deprecated Feature scheduled for future release, at present not implemented.
  692.         \else
  693.         Specifies the position of the sun, normally this is the upper left corner.
  694.  
  695.         \sa sunPos
  696.         \endif
  697.         */
  698.         void setSunPos( CornerName sunPos )
  699.         {
  700.             _sunPos = sunPos;
  701.         }
  702.  
  703.         /**
  704.         \ifnot v200
  705.         \deprecated Feature scheduled for future release, at present not implemented.
  706.         \else
  707.         Returns the position of the sun.
  708.  
  709.         \sa setSunPos
  710.         \endif
  711.         */
  712.         CornerName sunPos() const
  713.         {
  714.             return _sunPos;
  715.         }
  716.  
  717.  
  718.         /**
  719.         Specifies the brush to be used to fill the inner area of this frame,
  720.         calling this methode without passing in a parameter re-sets the background brush
  721.         to \c QBrush( \cQt::NoBrush \c).
  722.  
  723.         \Note To have a 'tiled' background image just use a brush
  724.         holding this pixmap - for other ways to show background
  725.         images please use setBackPixmap.
  726.  
  727.         \sa setBackPixmap, background
  728.         */
  729.         void setBackground( QBrush background = QBrush( Qt::NoBrush ) )
  730.         {
  731.             _background = background;
  732.         }
  733.  
  734.         /**
  735.         Specifies a pixmap to be used to fill the inner area of this frame,
  736.         calling this methode without passing in a parameter removes the background pixmap.
  737.  
  738.         \Note To have a 'tiled' background image do not use setBackPixmap
  739.         but use setBackground specifying a brush holding the pixmap.
  740.  
  741.         \sa setBackground, background
  742.         */
  743.         void setBackPixmap( const QPixmap* backPixmap     = 0,
  744.                 BackPixmapMode backPixmapMode = PixStretched )
  745.         {
  746.             _backPixmap     = backPixmap ? *backPixmap : QPixmap();
  747.             _backPixmapMode = backPixmapMode;
  748.         }
  749.  
  750.         /**
  751.         Returns the brush that is used to fill the inner area of this frame,
  752.         or a QBrush( \cNoBrush \c) if no background is to be drawn.
  753.  
  754.         \param backPixmap receives the pixmap used for drawing the background or
  755.         a null pixmap, test this by calling backPixmap.isNull()
  756.  
  757.         \Note If a 'tiled' background image is shown the respective pixmap
  758.         may be found by calling the <b>brush's</b> pixmap() function.
  759.  
  760.         \sa setBackground, setBackPixmap
  761.         */
  762.         const QBrush& background( const QPixmap*& backPixmap,
  763.                 BackPixmapMode& backPixmapMode ) const
  764.         {
  765.             backPixmap     = &_backPixmap;
  766.             backPixmapMode =  _backPixmapMode;
  767.             return _background;
  768.         }
  769.  
  770.  
  771.         /**
  772.         Specifies the position and the size of area that is surrounded by the frame.
  773.  
  774.         \note The rectangle applies to the <b>inner</b> area of the frame.
  775.         The Frame is drawn around this area: touching it but not covering it.
  776.         The outer size of the frame and the position of its outer left corner
  777.         depends from the frame profile width(s).
  778.  
  779.         \sa innerRect, setCorners, setSimpleFrame, setProfile
  780.         */
  781.         void setInnerRect( QRect innerRect )
  782.         {
  783.             _innerRect = innerRect;
  784.         }
  785.  
  786.         /**
  787.         Returns the position and the size of the frame.
  788.  
  789.         \note The rectangle returns to the <b>inner</b> area of the frame.
  790.         The Frame is drawn around this area: touching it but not covering it.
  791.         The outer size of the frame and the position of its outer left corner
  792.         depends from the frame profile width.
  793.  
  794.         \sa setInnerRect, setProfile
  795.         */
  796.         QRect innerRect() const
  797.         {
  798.             return _innerRect;
  799.         }
  800.  
  801.  
  802.         /**
  803.         Paint methode drawing the background (if any) of the frame.
  804.  
  805.         \note Under normal circumstances you will <b>never</b> have to
  806.         call this methode since it is called internally by paint() if you
  807.         start it with  \c PaintBackground (or with \c PaintAll, resp.) for the \c steps parameter.
  808.         */
  809.         virtual void paintBackground( QPainter& painter, const QRect& innerRect ) const;
  810.         /**
  811.         Paint methode drawing the edges (if any) of the frame.
  812.  
  813.         \note Under normal circumstances you will <b>never</b> have to
  814.         call this methode since it is called internally by paint() if you
  815.         start it with \c PaintEdges (or with \c PaintAll, \c PaintBorder, resp.) for the \c steps parameter.
  816.         */
  817.         virtual void paintEdges( QPainter& painter, const QRect& innerRect ) const;
  818.         /**
  819.         Paint methode drawing the corners (if any) of the frame.
  820.  
  821.         \note Under normal circumstances you will <b>never</b> have to
  822.         call this methode since it is called internally by paint() if you
  823.         start it with \c PaintCorners (or with \c PaintAll, \c PaintBorder, resp.) for the \c steps parameter.
  824.         */
  825.         virtual void paintCorners( QPainter& painter, const QRect& innerRect ) const;
  826.  
  827.  
  828. public:
  829.         /**
  830.         The different steps taken to paint the frame:
  831.         first paint the background then the edges then the corners.
  832.         By choosing \c PaintAll all the parts of the frame will be drawn.
  833.  
  834.         \li \c PaintBackground -- first paints the brush, then paints the pixmap if any
  835.         \li \c PaintEdges
  836.         \li \c PaintCorners
  837.         \li \c PaintBorder -- paint the edges and the corners but not the background
  838.         \li \c PaintAll
  839.  
  840.         \sa paint
  841.         */
  842.         enum KDFramePaintSteps { PaintBackground, PaintEdges, PaintCorners, PaintBorder, PaintAll };
  843.  
  844. public slots:
  845.  
  846.         /**
  847.         Paint methode actually drawing the frame.
  848.  
  849.         This method must be called from inside the \c paint() methode of your widget.
  850.  
  851.         In order not to override the inner contents of the frame you normally would
  852.         first call <b>paint( painter, PaintBackground );</b> then do all the inside
  853.         drawing and finally call <b>paint( painter, PaintBorder );</b>. In case the
  854.         inner contents <b>are</b> allowed to (partially) override the frame border
  855.         you could do the following: First call <b>paint( painter, PaintBackground );</b>
  856.         immediately followed by <b>paint( painter, PaintEdges );</b> then do all your
  857.         inside work and finally draw <b>paint( painter, PaintCorners );</b>.
  858.  
  859.         \param painter The QPainter to be used for drawing.
  860.         \param steps The part of the frame to be drawn, use KDFrame::PaintAll to draw the entire frame and the background,
  861.         use KDFrame::PaintBackground to draw only the background, use KDFrame::PaintEdges to draw just the edges,
  862.         use KDFrame::PaintCorners to draw only the corners.
  863.         \param innerRect The area inside the frame. Use this parameter to temporarily override the \c innerRect set by
  864.         the constructor of KDFrame or by setInnerRect(). This approach can be usefull if you want to draw several
  865.         frames that differ only regarding to their position and size but share the same edges/corners/background settings.
  866.         In this case you could decide to instantiate only one KDFrame set up the desired settings and just call
  867.         its paint() methode several time - giving it the appropriate innerRect for each frame. This would result in
  868.         less memory usage since you could use that single KDFrame object as kind of a shared ressource.
  869.         */
  870.         virtual void paint( QPainter* painter,
  871.                 KDFramePaintSteps steps = PaintAll,
  872.                 QRect innerRect         = QRect(0,0,0,0) ) const;
  873.  
  874.  
  875.         /**
  876.         Remove all settings and specify no border, no edges, no background.
  877.         */
  878.         void clearAll()
  879.         {
  880.             _background     = QBrush();
  881.             _backPixmap     = QPixmap();
  882.             _backPixmapMode = PixStretched;
  883.             _shadowWidth    = 0;
  884.             _sunPos         = CornerTopLeft;
  885.             _innerRect      = QRect( 0,0, 0,0 );
  886.             _topProfile.clear();
  887.             _rightProfile.clear();
  888.             _bottomProfile.clear();
  889.             _leftProfile.clear();
  890.             _cornerTL.setAll( CornerNormal, 0, 0 );
  891.             _cornerTR.setAll( CornerNormal, 0, 0 );
  892.             _cornerBL.setAll( CornerNormal, 0, 0 );
  893.             _cornerBR.setAll( CornerNormal, 0, 0 );
  894.         }
  895.  
  896. public:
  897.  
  898.     /**
  899.     Default Constructor. Defines default values.
  900.  
  901.     The constructor does *not* have a \c parent parameter since drawing
  902.     of the frame is not done transparently but by (one or more) explicit
  903.     calls of the frames paint() methode.  See explanation given there
  904.     to learn about the why and how of this...
  905.  
  906.     \note The rectangle applies to the <b>inner</b> area of the frame.
  907.     The Frame is drawn around this area: touching it but not covering it.
  908.     The outer size of the frame and the position of its outer left corner
  909.     depends from the frame profile width.
  910.  
  911.     \Note To have a 'tiled' background image do not specify a backPixmap
  912.     but use a background <b>brush</b> holding this pixmap.
  913.  
  914.     \sa rect, setInnerRect, setProfile
  915.     */
  916.     KDFrame( QRect          innerRect      = QRect(0,0,0,0),
  917.             SimpleFrame    frame          = FrameFlat,
  918.             int            lineWidth      = 1,
  919.             int            midLineWidth   = 0,
  920.             QPen           pen            = QPen(),   // solid black line with 0 width
  921.             QBrush         background     = QBrush(), // no brush
  922.             const QPixmap* backPixmap     = 0,        // no pixmap
  923.             BackPixmapMode backPixmapMode = PixStretched,
  924.             int            shadowWidth    = 0,
  925.             CornerName     sunPos         = CornerTopLeft )
  926.     {
  927.         _profileSections.setAutoDelete( true );
  928.         _innerRect = innerRect;
  929.         setSimpleFrame( frame,
  930.                         lineWidth,
  931.                         midLineWidth,
  932.                         pen,
  933.                         background,
  934.                         backPixmap,
  935.                         backPixmapMode );
  936.         _shadowWidth = shadowWidth;
  937.         _sunPos      = sunPos;
  938.     }
  939.  
  940.  
  941. /*
  942.     Constructor. Set up a frame by copying settings of another frame.
  943.  
  944.     The constructor does *not* have a \c parent parameter since drawing
  945.     of the frame is not done transparently but by (one or more) explicit
  946.     calls of the frames paint() methode.  See explanation given there
  947.     to learn about the why and how of this...
  948.  
  949.     \note The rectangle applies to the <b>inner</b> area of the frame.
  950.     The Frame is drawn around this area: touching it but not covering it.
  951.     The outer size of the frame and the position of its outer left corner
  952.     depends from the frame profile width.
  953.  
  954.     \sa rect, setInnerRect, setProfile
  955.  
  956.     KDFrame( QRect innerRect,
  957.             const KDFrame& R,
  958.             CornerName sunPos = CornerUNKNOWN )
  959.     {
  960.         deepCopy( *this, R );
  961.         if( innerRect.isValid() )
  962.             _innerRect = innerRect;
  963.         if( CornerUNKNOWN != sunPos )
  964.             _sunPos = sunPos;
  965.  
  966.         _profileSections.setAutoDelete( true );
  967.     }
  968. */
  969. private:
  970.     KDFrame( const KDFrame& ) : QObject(0) {}
  971.     KDFrame& operator=( const KDFrame& ){return *this;}
  972.  
  973.  
  974.  
  975. public:
  976.     /**
  977.     Destructor. Only defined to have it virtual.
  978.     */
  979.     virtual ~KDFrame();
  980.  
  981.     /*
  982.     Kopierroutine, aufgerufen im Copy-C'tor und im Zuweisungs-Operator
  983.     */
  984.     static void deepCopy( KDFrame& D, const KDFrame& R )
  985.     {
  986.         D._shadowWidth    = R._shadowWidth;
  987.         D._sunPos         = R._sunPos;
  988.         D._background     = R._background;
  989.         D._backPixmap     = R._backPixmap;
  990.         D._backPixmapMode = R._backPixmapMode;
  991.         D._innerRect      = R._innerRect;
  992.         D._topProfile     = R._topProfile;
  993.         D._rightProfile   = R._rightProfile;
  994.         D._bottomProfile  = R._bottomProfile;
  995.         D._leftProfile    = R._leftProfile;
  996.         D._cornerTL       = R._cornerTL;
  997.         D._cornerTR       = R._cornerTR;
  998.         D._cornerBL       = R._cornerBL;
  999.         D._cornerBR       = R._cornerBR;
  1000.         D._profileSections= R._profileSections;
  1001.         D._profileSections.setAutoDelete( true );
  1002.         R.setProfileSectionsAutoDelete( false );
  1003.     }
  1004.  
  1005.     friend QTextStream& operator<<( QTextStream& s, const KDFrame& p );
  1006.     friend QTextStream& operator>>( QTextStream& s, KDFrame& p );
  1007.  
  1008.     /**
  1009.     Creates a DOM element node that represents a frame for use
  1010.     in a DOM document.
  1011.  
  1012.     \param document the DOM document to which the node will belong
  1013.     \param parent the parent node to which the new node will be appended
  1014.     \param elementName the name of the new node
  1015.     \param frame the frame to be represented
  1016.     */
  1017.     static void createFrameNode( QDomDocument& document, QDomNode& parent,
  1018.             const QString& elementName,
  1019.             const KDFrame& frame );
  1020.  
  1021.     /**
  1022.     Creates a DOM element node that represents a frame profile for use
  1023.     in a DOM document.
  1024.  
  1025.     \param document the DOM document to which the node will belong
  1026.     \param parent the parent node to which the new node will be appended
  1027.     \param elementName the name of the new node
  1028.     \param profile the profile to be represented
  1029.     */
  1030.     static void createFrameProfileNode( QDomDocument& document,
  1031.             QDomNode& parent,
  1032.             const QString& elementName,
  1033.             KDFrameProfile profile );
  1034.  
  1035.     /**
  1036.     Reads data from a DOM element node that represents a frame
  1037.     object and fills a KDFrame object with the data.
  1038.  
  1039.     \param element the DOM element to read from
  1040.     \param frame the frame object to read the data into
  1041.     */
  1042.     static bool readFrameNode( const QDomElement& element,
  1043.             KDFrame& frame );
  1044.  
  1045.     /**
  1046.     Reads data from a DOM element node that represents a frame
  1047.     profile and fills a KDFrameProfile object with the data.
  1048.  
  1049.     \param element the DOM element to read from
  1050.     \param profile the frame profile object to read the data into
  1051.     */
  1052.     static bool readFrameProfileNode( const QDomElement& element,
  1053.             KDFrameProfile& profile );
  1054.  
  1055. signals:
  1056.     /**
  1057.     This signal is emitted when any of the frame parameters has changed.
  1058.     */
  1059.     void changed();
  1060.  
  1061. private:
  1062.     void setProfileSectionsAutoDelete( bool on ) const
  1063.     {
  1064.         ((KDFrame*)this)->_profileSections.setAutoDelete( on );
  1065.     }
  1066.  
  1067.     /**
  1068.     Stores the width of the shadow.
  1069.     */
  1070.     int _shadowWidth;
  1071.  
  1072.     /**
  1073.     Stores the position of the sun.
  1074.     */
  1075.     CornerName _sunPos;
  1076.  
  1077.     /**
  1078.     Stores the brush to be used to fill the inner area.
  1079.     */
  1080.     QBrush _background;
  1081.  
  1082.     /**
  1083.     Stores the pixmap to be painted into the inner area.
  1084.     */
  1085.     QPixmap _backPixmap;
  1086.  
  1087.     /**
  1088.     Stores the way how to display the pixmap that is
  1089.     to be painted into the inner area.
  1090.     */
  1091.     BackPixmapMode _backPixmapMode;
  1092.  
  1093.     /**
  1094.     Stores the position and size of the frame.
  1095.     */
  1096.     QRect _innerRect;
  1097.  
  1098.     /**
  1099.     Stores all currently used profile settings for a controlled deletion.
  1100.  
  1101.     \note The other pointer lists (like _topProfile or _rightProfile)
  1102.     do NOT delete the objects that belong to their pointers,
  1103.     but all sections will be deleted via this extra _profileSections list:
  1104.     this allows for using the same KDFrameProfileSection* to be used
  1105.     by several lists - typically done for simple frames where all 4 sides
  1106.     are composed the same way.
  1107.     */
  1108.     KDFrameProfile _profileSections;
  1109.  
  1110.     /**
  1111.     Stores the profile settings for the top side of the frame.
  1112.     */
  1113.     KDFrameProfile _topProfile;
  1114.     /**
  1115.     Stores the profile settings for the right side of the frame.
  1116.     */
  1117.     KDFrameProfile _rightProfile;
  1118.     /**
  1119.     Stores the profile settings for the bottom side of the frame.
  1120.     */
  1121.     KDFrameProfile _bottomProfile;
  1122.     /**
  1123.     Stores the profile settings for the left side of the frame.
  1124.     */
  1125.     KDFrameProfile _leftProfile;
  1126.  
  1127.     /**
  1128.     Stores the settings for the top left corner of the frame.
  1129.     */
  1130.     KDFrameCorner _cornerTL;
  1131.     /**
  1132.     Stores the settings for the top right corner of the frame.
  1133.     */
  1134.     KDFrameCorner _cornerTR;
  1135.     /**
  1136.     Stores the settings for the bottom left corner of the frame.
  1137.     */
  1138.     KDFrameCorner _cornerBL;
  1139.     /**
  1140.     Stores the settings for the bottom right corner of the frame.
  1141.     */
  1142.     KDFrameCorner _cornerBR;
  1143. };
  1144.  
  1145.  
  1146. /**
  1147.   Writes the KDFrame object p as an XML document to the text stream s.
  1148.  
  1149.   \param s the text stream to write to
  1150.   \param p the KDFrame object to write
  1151.   \return the text stream after the write operation
  1152.   */
  1153. QTextStream& operator<<( QTextStream& s, const KDFrame& p );
  1154.  
  1155.  
  1156. /**
  1157.   Reads the an XML document from the text stream s into the
  1158.   KDFrame object p
  1159.  
  1160.   \param s the text stream to read from
  1161.   \param p the KDFrame object to read into
  1162.   \return the text stream after the read operation
  1163.   */
  1164. QTextStream& operator>>( QTextStream& s, KDFrame& p );
  1165.  
  1166.  
  1167. #endif
  1168.